package unseen;

import java.sql.Array;
import java.util.Arrays;

public class test3 {
    public static void main(String[] args) {
        Student[] student=new Student[]{
                new Student("zhangsan",12),
                new Student("lisi",11),
                new Student("wangwu",13),
        };
        Arrays.sort(student);
        System.out.println(Arrays.toString(student));
    }
}
class Student implements Comparable{
    public String name;
    public int age;
    public Student(String name,int age){
        this.name=name;
        this.age=age;
    }
    public String toString(){
        return "["+this.name+":"+this.age+"]";
    }
    @Override
    public int compareTo(Object o) {
        Student student=(Student) o;
        return this.age-student.age;
    }
}
